package com.whz.http.web;

import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * global filter register configure
 *
 * @author whz
 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class GlobalWebFilterConfiguration {

    @Bean
    public FilterRegistrationBean<GlobalSecurityFilter> registerGlobalSecurityFilter() {
        FilterRegistrationBean<GlobalSecurityFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new GlobalSecurityFilter());
        registration.addUrlPatterns("/*");
        registration.setName("GenericGlobalSecurityFilter");
        //值越小,Filter越靠前
        registration.setOrder(100);
        return registration;
    }
}